/* ResetBehaviorDecorator class implementation
 *
*/

#include "ResetBehaviorDecorator.h"
#include "ParentBehaviorController.h"

void ResetBehaviorDecorator::Execute() 
{
	assert(behavior);
	DEBUG_PRINT("ResetBehaviorDecorator(%p) executes resetting controller(%p).\n",this, behavior->GetControl());
	if(repeat){

		while(!behavior->GetControl()->Finished())
			behavior->Execute();
	}
	if(behavior->GetControl()->Finished())
	{
		DEBUG_PRINT("ResetBehaviorDecorator(%p) calls controller(%p) for reset on Finished.\n",this, behavior->GetControl());
		((ParentBehaviorController*)behavior->GetControl())->Reset();
	}
}